package com.demo.quartz;

import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

public class HelloJob1 implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        // 实现业务逻辑，相当于run
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(date));
        Trigger currentTrigger = jobExecutionContext.getTrigger();
        System.out.println("Start Time is: " + sdf.format(currentTrigger.getStartTime()));
        System.out.println("End Time is: " + sdf.format(currentTrigger.getEndTime()));
        JobKey jobKey = currentTrigger.getJobKey();
        System.out.println(jobKey.getName() + "," + jobKey.getGroup());
    }
}
